#ifndef _MQTTCLIENT_MQTTPROXY_H_
#define _MQTTCLIENT_MQTTPROXY_H_

#include <QObject>
#include "MQTTAsync.h"
#include "PublicStruct.h"

class CMqttProxy : public QObject
{
	Q_OBJECT
public:
	CMqttProxy(const CConnectOpt& opt, QObject *parent = nullptr);
	~CMqttProxy();
	void newMessage(const QString& strTopicName, const QString& strMsg);

signals:
	void sigError(QString);

private:
	void initConnect();
	static void delivered(void *pContext, MQTTAsync_token dt);
	static int msgarrvd(void *pContext, char *pTopicName, int topicLen, MQTTAsync_message *pMessage);
	static void connlost(void *pContext, char *pCause);

private:
	MQTTAsync m_client;
	CConnectOpt m_opt;
};

#endif